﻿



#ifndef BNS_H
#define BNS_H

#include <stdio.h>
#include <Windows.h>
#include <iostream>


typedef std::pair<double, double> point2f;
#define X_ first
#define Y_ second


#define HANDLE_ERROR(err) if (err != cudaSuccess){\
	fprintf(stderr, "%s: [%s , %d]\n", cudaGetErrorString(err), \
	__FILE__, __LINE__); exit(EXIT_FAILURE); }


#define HANDLE_NULL(ptr) if (!ptr){\
	fprintf(stderr, #ptr" = NULL: [%s , %d]\n", __FILE__, \
	__LINE__); \
	exit(EXIT_FAILURE); }


//
//static void help()
//{
//	printf("------HUONG DAN SU DUNG CHUONG TRINH-------\n"
//		"\n[a] [b] [c] [d] [e] [f]\n\n"
//		"[a]: Duong dan anh can lam viec\n"
//		"[b]: Duong dan anh ket qua\n"
//		"[c]: -CPU hoac -OPENMP hoac -GPU. Mac dinh CPU\n"
//		"[d]: So Threads tren mot Block. Mac dinh 32 threads\n"
//		"[e]: So Block su dung. Mac dinh la 32 blocks\n"
//		"[f]: So Byte mot Thread phai thuc hien. Mac dinh la 1000\n"
//		"Chu y: [d][e][f] dung khi su dung GPU\n");
//}

void docMotVung(FILE* filePtr, BYTE headerSize, int x0, int y0, int cx,
	int cy, int bytesPerPixel, int rowLength, BYTE* &outPtr);


void tinhNghichDao(double f[6], double g[6]);


void docPhanHeader(FILE *filePtr, int* width, int* height, int* depth,
	int* rowLength, int* headerSize);


inline point2f TinhGiaTri(const double *f, const point2f &p)
{
	return point2f(
		f[0] * p.X_ + f[1] * p.Y_ + f[2],
		f[3] * p.X_ + f[4] * p.Y_ + f[5]);
}


#endif